public class Solution83 {

    public static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    public ListNode deleteDuplicates(ListNode head) {
        if (head==null){
            return null;
        }
        ListNode n=head;
        while (n.next!=null){
            if (n.val==n.next.val){
                n.next=n.next.next;
            }else{
                n=n.next;
            }
        }
        return head;
    }

    public static void main(String[] args) {
        System.out.println(new Solution83().deleteDuplicates(new ListNode(1,new ListNode(1,new ListNode(2)))).next.val);
    }
}
